package com.hgw.Demo01_SimpleFactory.Exercises3_9_4;

/**
 * Data time:2021/12/11 16:57
 * StudentID:2019112118
 * Author:hgw
 * Description:
 */
public class CreatePersonFactory {

    public static Person createPerson(String type) {
        Person person = null;
        if ("M".equals(type)) {
            person = new ManPerson();
        } else if ("W".equals(type)) {
            person = new WomanPerson();
        } else {
            throw new RuntimeException("对不起，造不出来！");
        }
        return person;
    }
}
